# Contributor: Ben Pye <ben@curlybracket.co.uk>
# Maintainer: Krassy Boykinov <kboykinov@teamcentrixx.com>
pkgname=libunwind
pkgver=1.7.2
pkgrel=1
pkgdesc="Portable and efficient C programming interface (API) to determine the call-chain of a program"
url="https://www.nongnu.org/libunwind/"
arch="all"
license="MIT"
options="!check" # v1.4.0 12 tests failing - https://github.com/libunwind/libunwind/issues/164
depends_dev="libucontext-dev"
makedepends_build="autoconf automake libtool"
makedepends_host="$depends_dev linux-headers xz-dev"
makedepends="$makedepends_build $makedepends_host"
subpackages="$pkgname-dbg $pkgname-static $pkgname-dev $pkgname-doc"
source="https://github.com/libunwind/libunwind/releases/download/v$pkgver/libunwind-$pkgver.tar.gz
	force-enable-man.patch
	fix-libunwind-pc-in.patch
	"

build() {
	# shellcheck disable=2046
	LDFLAGS="$LDFLAGS -lucontext" CFLAGS="$CFLAGS -fno-stack-protector" \
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-cxx-exceptions \
		$(want_check || echo --disable-tests)
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
903f7e26c7d4c22e6ef4fe8954ca0f153fdf346cec40e1e8f7ab966d251110f4deb0a84d1fd150aee194ed966b5c1e01ee27c821cd043859852da33a94faae1f  libunwind-1.7.2.tar.gz
0a6de92aba6624298df4173e075947112369d6d59c0db8ba58d59611f799ba0f192515d3493304de8125a11b67529517e5d830f05ff5d4fc86b8cca6ca2872b8  force-enable-man.patch
ab5d44e9d3aaf32e3119fe79389e5dfcdc859c78cfda8400e54ee29fd1cdf04b99e2686caf18ab0b76ac94f861861d69a5cf740d46967af9c630095485523f1c  fix-libunwind-pc-in.patch
"
